<script setup>
// 第三方模块
import { computed } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();

// 仓库  自定义
import useUserStore from "@/stores/user.js";
const userStore = useUserStore();

// 获取用户信息
const user = computed(() => {
  return userStore.userList.find((item) => item.name === "zhangsan");
});


// 地址跳转
const add = () => {
  router.push({
    path: "/address",
  });
};
</script>

<template>
  <div class="my">
    <div class="header">
      <div class="person">
        <!-- 头像 -->
        <div class="person_avatar">
          <img :src="user.imgUrl" alt="" />
        </div>
        <!-- 个人信息 -->
        <div class="person_info">
          <div class="person_info_name">{{ user.name }}</div>
          <div class="person_info_id">ID: {{ user.id }}</div>
        </div>
        <!-- 列表信息 -->
        <div class="person_message">
          <div
            class="person_message_item"
            v-for="(item, index) in user.list"
            :key="index"
          >
            <div class="person_message_item_title">{{ item.title }}</div>
            <div class="person_message_item_content">{{ item.content }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="list">
      <!-- 功能列表 -->
      <div class="list_item">
        <span class="iconfont list_item_icon list_item_wallet">&#xe631;</span>
        <div class="list_item_message">我的钱包</div>
        <span class="iconfont list_item_arrow">&#xe8f1;</span>
      </div>
      <div class="list_item" @click="add">
        <span class="iconfont list_item_icon list_item_address">&#xe60d;</span>
        <div class="list_item_message">我的地址</div>
        <span class="iconfont list_item_arrow">&#xe8f1;</span>
      </div>
      <div class="list_item">
        <span class="iconfont list_item_icon list_item_help">&#xe616;</span>
        <div class="list_item_message">客服与帮助</div>
        <span class="iconfont list_item_arrow">&#xe8f1;</span>
      </div>
    </div>
    <div class="logout">退出登录</div>
  </div>
</template>

<style lang="scss" scoped>
@import "@/style/viriables.scss";
.my {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;

  .header {
    position: relative;
    height: 2.5rem;
    background-image: linear-gradient(239deg, #3a6ff3 0%, #50c7fb 100%);
    border-radius: 0 0 35% 35%;

    .person {
      position: absolute;
      top: 1rem;
      left: 0.18rem;
      right: 0.18rem;
      background-color: $bgColor;
      padding-top: 0.6rem;
      border-radius: 0.08rem;
      box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.08);
      //头像
      &_avatar {
        position: absolute;
        left: 50%;
        top: -0.47rem;
        transform: translateX(-50%);
        border-radius: 50%;
        overflow: hidden;
        z-index: 1;

        img {
          width: 0.94rem;
          height: 0.94rem;
          display: block;
        }
      }
      //个人信息
      &_info {
        border-bottom: 0.01rem solid $content_bgColor;
        padding: 0.16rem 0;

        &_name {
          line-height: 0.36rem;
          text-align: center;
          font-size: 0.24rem;
          color: #262628;
        }
        &_id {
          text-align: center;
          font-size: 0.14rem;
          color: #c1c0c9;
        }
      }
      //列表信息
      &_message {
        padding: 0.16rem 0.28rem;
        display: flex;

        &_item {
          flex: 1;
          text-align: center;

          &_title {
            color: #c1c0c9;
          }
          &_content {
            font-size: 0.2rem;
            color: #262628;
            margin-top: 0.03rem;
          }
        }
      }
    }
  }

  .list {
    margin: 1rem 0.18rem 0 0.18rem;
    border-radius: 0.08rem;
    box-shadow: 0 0 0.16rem 0.08rem rgba(0, 0, 0, 0.08);

    &_item {
      display: flex;
      align-items: center;
      padding: 0.12rem 0.16rem;
      //图标
      &_icon {
        font-size: 0.16rem;
        padding: 0.03rem;
        color: $bgColor;
        border-radius: 0.08rem;
        margin-right: 0.16rem;
      }
      // 钱包
      &_wallet {
        background-color: #ed4a47;
      }
      // 地址
      &_address {
        background-color: #32c5ff;
      }
      //客服与帮助
      &_help {
        background-color: #9013fe;
      }
      //文字
      &_message {
        flex: 1;
        font-size: 0.14rem;
      }
    }
  }

  .logout {
    margin: 0.18rem;
    line-height: 0.32rem;
    background-color: $btn_bgColor;
    color: $bgColor;
    text-align: center;
    border-radius: 0.04rem;
  }
}
</style>